package fr.flambycrew.util;

import org.apache.commons.lang3.StringUtils;
import org.htmlcleaner.TagNode;

public abstract class NodeUtil {
	
	public static final String TRASH_TEXT = "/n";
	public static final String LINE_BREAK = "[\\u00A0]";
	public static final String DOUBLE_SPACE = "[\\u0020][\\u0020]";
	
	public static String getCleanContent(TagNode node){
		return (node == null) ? null : getCleanContent(node.getText().toString());
	}
	
	public static String getCleanContent(String rawContent){
		return (rawContent == null) ? null : rawContent.replaceAll(TRASH_TEXT, StringUtils.EMPTY).replaceAll(DOUBLE_SPACE, StringUtils.EMPTY) .trim().replaceAll(LINE_BREAK, StringUtils.EMPTY).trim();
	}

}
